#include "cThreadHelper.h"
#include <stdio.h>
#include <stdlib.h>
#include <thread>
#include <chrono>

namespace libcvos_vfr
{
	namespace Helper
	{

		void Tool_sleepForMillsecond(unsigned long millisecond)
		{
			std::this_thread::sleep_for(std::chrono::milliseconds(millisecond));
		}

#ifdef _WIN32
#else
        pid_t Tool_getProcessPidByName(const char *proc_name)
        {
            FILE *fp;
            char buf[256];
            char cmd[256] = {'\0'};
            pid_t pid = -1;
            sprintf(cmd, "pidof %s", proc_name);

            if((fp = popen(cmd, "r")) != NULL)
            {
                if(fgets(buf, sizeof(buf), fp) != NULL)
                {
                    pid = atoi(buf);
                }
            }

            //printf("pid = %d \n", pid);

            pclose(fp);
            return pid;
        }
#endif

	}
}
